package niu.toy.spring.mvc.impl;

import niu.toy.spring.ioc.annotation.Nullable;
import niu.toy.spring.mvc.NativeWebRequest;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 封装request,response
 */
public class ServletWebRequest implements NativeWebRequest {
    private final HttpServletRequest request;
    private HttpServletResponse response;
    private volatile boolean requestActive = true;

    public ServletWebRequest(HttpServletRequest request, @Nullable HttpServletResponse response) {
        this.request = request;
        this.response = response;
    }

    @Override
    public Object getNativeRequest() {
        return this.request;
    }
    @Override
    public Object getNativeResponse() {
        return this.response;
    }

    public void requestCompleted() {
        this.requestActive = false;
    }
    protected final boolean isRequestActive() {
        return this.requestActive;
    }
}
